import random


class Person:

    def __init__(self, name, money):
        self.name = name
        self.money = money

    # 报数
    def show(self):
        print(f"我是{self.name},现在有{self.money}元")


class Manager(Person):

    def send(self, money: int, num: int):
        # 发红包
        red_list = []
        if money  > self.money:
            print("您的余额不足")
        else:
            # 扣钱
            self.money -= money

            # 分红包
            avg = money // num
            mod = money % num

            # 先平均分
            for x in range(num):
                red_list.append(avg)
            # 如有余数，加到第一个红包里
            red_list[0] += mod

            return red_list


class Member(Person):
    # 抢红包


    def grab(self, red_list):
        print(f"{self.name}抢红包")
        if not red_list:
            return None
        # 从红包列表随机选一个
        random_index = random.randint(0, len(red_list) - 1)
        lucky_money = red_list.pop(random_index)

        # 存钱
        self.money += lucky_money
        return self.money


if __name__ == '__main__':
    manger = Manager("耿世杰", 1000)
    a = Member("a", 0)
    b = Member("b", 0)
    c = Member("c", 0)

    # 发红包
    red_li = manger.send(1000, 3)

    # 抢红包
    a.grab(red_li)
    b.grab(red_li)
    c.grab(red_li)

    # 报数
    manger.show()
    a.show()
    b.show()
    c.show()
